public class BM6 {
    public boolean hasCycle(BM4.ListNode head) {
        if(head == null || head.next == null){
            return false;
        }
        //快慢指针 追击相遇问题
        BM4.ListNode fastNode = head;
        BM4.ListNode slowNode = head;
        while(fastNode != null && fastNode.next != null){
            fastNode = fastNode.next.next;
            slowNode = slowNode.next;
            if(fastNode == slowNode){
                return true;
            }
        }
        return false;
    }
}
